﻿using System.Collections.Generic;
using System.Linq;
using ClientOverflow.DataTransferObjects;
using ClientOverflow.ViewModels.QuestionsListViewModels;

namespace ClientOverflow.ViewModels.UserProfileViewModels
{
    /// <summary>
    /// Composite pattern implementation for uniting criterias in questions filters.
    /// </summary>
    internal class CompositeQuestionsFilter : IQuestionsFilter
    {
        private readonly IEnumerable<IQuestionsFilter> filters;

        public CompositeQuestionsFilter(IEnumerable<IQuestionsFilter> filters)
        {
            this.filters = filters;
        }

        public bool IsFittingCrieteria(Question question)
        {
            return filters.All(filter => filter.IsFittingCrieteria(question));
        }
    }
}